import { stringify } from "qs";
import request from "../utils/request";
import { getToken } from "../utils/authority";

export async function getClientPage(params) {
  return request(`/admin/client/page?${stringify(params)}`, {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${getToken()}`,
    },
  });
}

export async function getClientById(params = {clientId: '#'}) {
  return request(`/admin/client/${params.clientId}`, {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${getToken()}`,
    },
  });
}

export async function addClient(params) {
  return request('/admin/client/', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${getToken()}`,
    },
    body: {
      ...params,
    },
  });
}

export async function updClient(params) {
  return request('/admin/client/', {
    method: 'PUT',
    headers: {
      Authorization: `Bearer ${getToken()}`,
    },
    body: {
      ...params,
    },
  });
}

export async function delClient(params) {
  return request(`/admin/client/${params.clientId}`, {
    method: 'DELETE',
    headers: {
      Authorization: `Bearer ${getToken()}`,
    },
  });
}
